import type { CommonResponseData } from '@/api/user/type'
import request from '@/utils/request'
import type { AttrData, AttrNameData } from './types'

const enum Api {
  ATTR_LIST = '/attr/list',
  ATTR_NAME_LIST = '/attrName/list',
  ADD_ATTR_NAME = '/attrName/add',
  DELETE_ATTR_NAME = '/attrName/delete',
}

export const reqAttrList = (parentId: number) =>
  request.get<any, CommonResponseData<AttrData[]>>(
    Api.ATTR_LIST + '?parentId=' + parentId
  )

export const rqaAttrNameList = (id: number) =>
  request.get<any, CommonResponseData<AttrNameData[]>>(
    Api.ATTR_NAME_LIST + '?attrId=' + id
  )

export const reqAddAttrName = (data: AttrNameData) =>
  request.post<any, CommonResponseData<boolean>>(Api.ADD_ATTR_NAME, data)

export const deleteAddAttrName = (attrNameId: number) =>
  request.delete<any, CommonResponseData<boolean>>(
    Api.DELETE_ATTR_NAME + '?attrNameId=' + attrNameId
  )
